using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using log4net;
using Ctx = Karma.Framework.Core.Security.Context;

namespace Cognitum.Presentacion
{
    public partial class _Default : Page
    {
        private static ILog LOG = LogManager.GetLogger (typeof (_Default));

        public string Username = String.Empty;

        public string Domain = String.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (LOG.IsDebugEnabled)
            {
                LOG.Debug("Entering Default.aspx");
            }
            if (!IsPostBack)
            {
                var identity = HttpContext.Current.User.Identity;
                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Current principal: " + identity.Name);
                }
                var datos = identity.Name.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                if (datos.Length == 0)
                {
                    Response.Redirect(FormsAuthentication.LoginUrl);
                }
                Username = datos[1];
                Domain = datos[0];
            }
        }
    }
}
